Skip to content

fix: support hyphenated Claude model names for Claude Code 2.1.x compatibility#250

Open
yang-builds wants to merge 1 commit intoericc-ch:masterfrom
yang-builds:fix/hyphenated-model-names
Open

fix: support hyphenated Claude model names for Claude Code 2.1.x compatibility#250
yang-builds wants to merge 1 commit intoericc-ch:masterfrom
yang-builds:fix/hyphenated-model-names

Conversation

@yang-builds
Copy link
Copy Markdown

Problem

Claude Code 2.1.x uses hyphenated model names (e.g. claude-sonnet-4-6) for its internal display mapping, but the GitHub Copilot backend only accepts dot notation (e.g. claude-sonnet-4.6).

The current translateModelName truncates claude-sonnet-4-6 to claude-sonnet-4, which causes:

  1. GitHub Copilot backend rejects the request with HTTP 400
  2. Claude Code welcome screen shows "Sonnet 4" instead of "Sonnet 4.6"

Root Cause

// Before — incorrect truncation
if (model.startsWith("claude-sonnet-4-")) {
  return model.replace(/^claude-sonnet-4-.*/, "claude-sonnet-4")  // ❌ drops minor version
}

claude-sonnet-4-6claude-sonnet-4rejected by Copilot backend

Fix

Replace with a regex that correctly converts hyphenated minor version to dot notation:

// After — correct conversion
const m = model.match(/^(claude-(?:sonnet|opus|haiku))-(\d+)-(\d+)$/)
if (m) return `${m[1]}-${m[2]}.${m[3]}`
Input Output Result
claude-sonnet-4-6 claude-sonnet-4.6 ✅ HTTP 200
claude-opus-4-7 claude-opus-4.7 ✅ HTTP 200
claude-haiku-4-5 claude-haiku-4.5 ✅ HTTP 200
claude-sonnet-4.6 claude-sonnet-4.6 ✅ passthrough (unchanged)

Future models (e.g. claude-sonnet-5-0) are automatically handled without any code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant